#include "Ogre/ExampleApplication.h"
#include "GameSphere.h"

//INCLUDE PRIME_SENSE CLASS
#include <XnVDeviceGenerator.h>
#include <XnVNite.h>
#include <XnTypes.h>
#include <XnV3DVector.h>

#include <vector>


class CustomFrameListener : public Ogre::FrameListener
{
private:	

	//SCENE MEMBERS
	Ogre::SceneManager* mSceneManager;

	//CHARACTER MEMBERS
	Ogre::SceneNode* _node;
	Ogre::Entity* _ent;

	//BALL MEMBERS
	//std::vector<Ogre::SceneNode*> balls;
	//std::vector<Ogre::Entity*> ballsEnt;
	std::vector<GameSphere*> balls;

	//CAMERA MEMBERS
	Ogre::Camera* _Cam;

	//INPUT MEMBERS
	OIS::InputManager* _man;
	OIS::Keyboard* _key;	
	OIS::Mouse* _mouse;

	//MOVEMENT MEMBERS
	float _WalkingSpeed;
	float _rotation;
	Real mPivotPitch;
	Vector3 mKeyDirection;
	Vector3 mGoalDirection;

	//PRIME_SENSE MEMBER
	xn::Context m_context;
	XnVSessionManager* m_sessionManager;
	xn::UserGenerator m_UserGenerator;
	XnUserID m_candidateID;

	//TIME
	Ogre::Real time;

	//COLLISION DETECTION
	void checkCollisions(const Real& i_deltaTime);

public:

	//CTOR
	CustomFrameListener();
	CustomFrameListener(Ogre::SceneManager* mSceneManager, Ogre::SceneNode* node,Ogre::Entity* ent, RenderWindow* win, Ogre::Camera* cam, xn::Context context, XnVSessionManager* sessionManager, xn::UserGenerator m_UserGenerator, XnUserID m_candidateID);

	//DTOR
	~CustomFrameListener();

	//SET/GET MEMBERS
	void setUserID(XnUserID i_userID)
	{
		m_candidateID = i_userID;
	}

	//UPDATE SKELETON
	void updateSkeleton();
	void transformBone(const Ogre::String& modelBoneName, XnSkeletonJoint skelJoint, bool flip=false);

	//UPDATE
	bool frameStarted(const Ogre::FrameEvent &evt);
	void updateBalls(const Ogre::Real& i_deltaTime);



};